import Mock from 'mockjs';
const Random = Mock.Random;

//利用mock生成数据
export const login = (_params)=>{
    let params = JSON.parse(_params.body);
    let data;
    if((params.name==='admin'&&params.pass==='1')||(params.name==='admin123'&&params.pass==='1')){
       data =  Mock.mock(
            {   'status':200,
                'success':true,
                'token': Random.guid(),
                'userInfo':{
                    'cname': "@cname",
                    'name':params.name,
                    'userId':params.name+params.pass,
                    'region':Random.region()
                }
            }
        );
    }else{
        data = {
            'success':false,
            'msg':'用户名或密码错误'
        }
    }
    return data
};